package com.blrs.controller;

import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.core.page.TableDataInfo;
import com.blrs.common.enums.BusinessType;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.domain.ContractPaymentMethod;
import com.blrs.domain.ProjectPaymentMethod;
import com.blrs.service.contract.IContractPaymentMethodService;
import com.blrs.service.project.productInfo.IProjectPaymentMethodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目收款方式 Controller
 * 
 * @author ruoyi
 * @date 2023-11-30
 */
@RestController
@RequestMapping("/projectPayment/method")
public class ProjectPaymentMethodController extends BaseController
{
    @Autowired
    private IProjectPaymentMethodService projectPaymentMethodService;

    /**
     * 查询【请填写功能名称】列表
     */
    //@PreAuthorize("@ss.hasPermi('system:method:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectPaymentMethod projectPaymentMethod)
    {
        startPage();
        List<ProjectPaymentMethod> list = projectPaymentMethodService.selectProjectPaymentMethodList(projectPaymentMethod);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    //@PreAuthorize("@ss.hasPermi('system:method:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectPaymentMethod projectPaymentMethod)
    {
        List<ProjectPaymentMethod> list = projectPaymentMethodService.selectProjectPaymentMethodList(projectPaymentMethod);
        ExcelUtil<ProjectPaymentMethod> util = new ExcelUtil<ProjectPaymentMethod>(ProjectPaymentMethod.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
   // @PreAuthorize("@ss.hasPermi('system:method:query')")
    @GetMapping(value = "/{paymentId}")
    public AjaxResult getInfo(@PathVariable("paymentId") String paymentId)
    {
        return success(projectPaymentMethodService.selectProjectPaymentMethodByPaymentId(paymentId));
    }

    /**
     * 新增【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:method:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectPaymentMethod projectPaymentMethod)
    {
        return toAjax(projectPaymentMethodService.insertProjectPaymentMethod(projectPaymentMethod));
    }

    /**
     * 修改【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:method:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectPaymentMethod projectPaymentMethod)
    {
        return toAjax(projectPaymentMethodService.updateProjectPaymentMethod(projectPaymentMethod));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:method:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentIds}")
    public AjaxResult remove(@PathVariable String[] paymentIds)
    {
        return toAjax(projectPaymentMethodService.deleteProjectPaymentMethodByPaymentIds(paymentIds));
    }
}
